-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: playground error when returning a function declaration VSCODE-669 #925
Conversation
src/language/worker.ts
Outdated
@@ -17,7 +16,7 @@ interface EvaluationResult { | |||
type: string | null; | |||
} | |||
|
|||
const getContent = ({ type, printable }: EvaluationResult): Document => { | |||
const getContent = ({ type, printable }: EvaluationResult): any => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could unknown
be better?
src/language/worker.ts
Outdated
): 'json' | 'plaintext' => { | ||
const content = getContent(evaluationResult); | ||
|
||
export const getLanguage = (content: any): 'json' | 'plaintext' => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could also potentially be unknown
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should default to plaintext
if this is not a json
. This defines the type of virtual document we open with a playground result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was referring to any
=> unknown
, I think we don't know much about the content then right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see! I thought you were talking about the return type.
Description
When the last statement in a playground is a function declaration, we would error out with a misleading error claiming the playground services crashed due to OOM. The reality was that we were trying to return a function via the language server protocol, which is not supported and was crashing the language server. This change replaces the printable when it is a function with
undefined
.Checklist
Motivation and Context
Types of changes